package com.code.day18;

import java.util.Iterator;
import java.util.LinkedList;

public class Demo01LinkedList {
    public static void main(String[] args) {
        LinkedList<String> list = new LinkedList<>();
        list.add("星际宝贝");
        list.add("恐龙宝贝");
        list.add("神奇宝贝");
        list.add("数码宝贝");
        list.addFirst("超级刘大胆");
        list.addLast("刘大胆");
        System.out.println(list);

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }
}
